<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('课程信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>是否及格：</label>
                            <select name="jige" th:with="type=${@dict.getType('cws_course_jige')}">
                                <option value=""></option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"
                                        th:attr="selected=(${jige} == ${dict.dictValue} ? true: false)"></option>
                            </select>
                        </li>
                        <li>
                            <input type="text" name="studentId" hidden="hidden" th:value="${studentId}"/>
                        </li>
                        <li>
                            <label>课程名称：</label>
                            <input type="text" name="courseName"/>
                        </li>
                        <li>
                            <label>学年：</label>
                            <input type="text" name="courseYear"/>
                        </li>
                        <li>
                            <label>上/下学期：</label>
                            <select name="isUp" th:with="type=${@dict.getType('cws_up_down_term')}">
                                <option value=""></option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
<!--                        <li>-->
<!--                            <label>选修课/必修课：</label>-->
<!--                            <select name="courseType" th:with="type=${@dict.getType('cws_course_type')}">-->
<!--                                <option value=""></option>-->
<!--                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
<!--                                        th:value="${dict.dictValue}"-->
<!--                                        th:attr="selected=(${dict.isDefault} == 'Y' ? true: false)"></option>-->
<!--                            </select>-->
<!--                        </li>-->
                        <li>
                            <label>是否结课：</label>
                            <select name="isCourseEnd" th:with="type=${@dict.getType('cws_course_yes_no')}">
                                <option value=""></option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var datas = [[${@dict.getType('cws_course_type')}]];
    var signInFlag = [[${@permission.hasPermi('cws:signinstudent:edit')}]];
    var prefix = ctx + "cws/course";
    var signinstudentPrefix = ctx + "cws/signinstudent";

    $(function () {
        var options = {
            url: prefix + "/student/list",
            modalName: "课程信息",
            columns: [{
                checkbox: true
                },
                {
                    field: 'courseId',
                    title: '',
                    visible: false
                },
                {
                    field: 'courseName',
                    title: '课程名称'
                },
                {
                    field: 'teacherName',
                    title: '教师'
                },
                {
                    field: 'clazzName',
                    title: '班级'
                },
                {
                    field: 'courseYear',
                    title: '学年'
                },
                {
                    field: 'isCourseEnd',
                    title: '是否结课',
                    align: 'center'
                },
                // {
                //     field: 'courseType',
                //     title: '选修课/必修课',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         return $.table.selectDictLabel(datas, value);
                //     }
                // },
                {
                    field: 'isUp',
                    title: '上/下学期',
                    align: 'center'
                },
                {
                    field: 'score',
                    title: '得分',
                    formatter: function (value, row, index) {
                        if(value == null){
                            return "未结课";
                        } else if (value < 60) {
                            return '<span style="color: red">' + value + '</span>';
                        } else {
                            return '<span style="color: green">' + value + '</span>';
                        }
                    }
                },
                {
                    field: 'gpa',
                    title: 'gpa',
                    formatter: function (value, row, index) {
                        if(value == null){
                            return "未结课";
                        } else if (value < 2) {
                            return '<span style="color: red">' + value + '</span>';
                        } else {
                            return '<span style="color: green">' + value + '</span>';
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + signInFlag + '" href="javascript:void(0)" onclick="signIn(\'' + row.courseId + '\',\'' + row.courseName + '\')"><i class="fa fa-adjust"></i>签到</a>');
                        return actions.join('');
                    }
                }
                ]
        };
        $.table.init(options);
    });

    function signIn(courseId,courseName) {
        $.modal.openTab(courseName + "签到",signinstudentPrefix + "/edit/" + courseId);
    }
</script>
</body>
</html>